﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SetSailView
{
    public partial class ShowInfo : Form
    {
        public ShowInfo()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 窗体
        /// </summary>
        /// <param name="content">提示内容</param>
        /// /// <param name="tip">图标状态</param>
        /// <param name="symbol">是否显示符号</param>
        /// <param name="title">提示标题</param>
        public ShowInfo(string content, TipState tip, bool symbol = true, string title = "")
        {
            InitializeComponent();
            if (content == null) content = "";
            label2.Text = content.Trim() + "！";
            switch (tip)
            {
                case TipState.sure:
                    pictureBox1.Image = SetSailReadFileTools.Properties.Resources.sure;
                    panel1.BackColor = Color.DodgerBlue;
                    ucBtnExt1.Location = new Point(200, 9);
                    ucBtnExt2.Visible = false;
                    label1.Text = "提示";
                    if (!string.IsNullOrWhiteSpace(title))
                        label1.Text = title.Trim();
                    break;
                case TipState.hint:
                    pictureBox1.Image = SetSailReadFileTools.Properties.Resources.hint;
                    panel1.BackColor = Color.Orange;
                    ucBtnExt1.Location = new Point(200, 9);
                    ucBtnExt2.Visible = false;
                    label1.Text = "提示";
                    if (!string.IsNullOrWhiteSpace(title))
                        label1.Text = title.Trim();
                    break;
                case TipState.query:
                    label2.Text = content.Trim() + "？";
                    pictureBox1.Image = SetSailReadFileTools.Properties.Resources.query;
                    panel1.BackColor = Color.SlateBlue;
                    ucBtnExt1.Location = new Point(130, 9);
                    ucBtnExt2.Visible = true;
                    label1.Text = "确认";
                    if (!string.IsNullOrWhiteSpace(title))
                        label1.Text = title.Trim();
                    break;
                case TipState.mistake:
                    pictureBox1.Image = SetSailReadFileTools.Properties.Resources.mistake;
                    panel1.BackColor = Color.OrangeRed;
                    ucBtnExt1.Location = new Point(200, 9);
                    ucBtnExt2.Visible = false;
                    label1.Text = "错误";
                    if (!string.IsNullOrWhiteSpace(title))
                        label1.Text = title.Trim();
                    break;
                default:
                    pictureBox1.Image = SetSailReadFileTools.Properties.Resources.sure;
                    panel1.BackColor = Color.DodgerBlue;
                    ucBtnExt1.Location = new Point(200, 9);
                    ucBtnExt2.Visible = false;
                    label1.Text = "提示";
                    if (!string.IsNullOrWhiteSpace(title))
                        label1.Text = title.Trim();
                    break;
            }
            if (!symbol)
                label2.Text = content.Trim();
        }

        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ucBtnExt1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ucBtnExt2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ucBtnExt1_BtnClick(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ucBtnExt2_BtnClick(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}
